#include "include.h"
#include "func.h"
#include "func_idle.h"

#if FUNC_IDLE_EN
extern void func_ilde_timeout(void);
u8 idle_hold_cnt=0;
AT(.text.func.idle.msg)
void func_idle_message(u16 msg)
{
    switch (msg) {
		case KEY_POWER:
			func_cb.sta=FUNC_BT;
			break;
		case KU_HSF:
    	{
    		u8 light_mode;
			idle_hold_cnt=0;
    		light_mode=bsp_set_light_mode();
			idle_reset_light_idle_timeout();
    	}
		break;
		case KL_HSF:
			bsp_set_pwm_mode();
			idle_reset_light_idle_timeout();
			break;
		case KH_HSF:
			if(idle_hold_cnt>107)
			{
				break;
			}
			idle_hold_cnt++;
			printf("hold cnt:%d\n",idle_hold_cnt);
			if(idle_hold_cnt%4==0)
			{
				bsp_set_pwm_mode();
				bt_reset_light_idle_timeout();
			}		
			break;
		case KLU_HSF:
			idle_hold_cnt=0;
			break;
		case MSG_SYS_1S:
			func_ilde_timeout();
			break;
        default:
            func_message(msg);
            break;
    }
}
#endif // FUNC_IDLE_EN
